<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" lang="zh" xmlns:th="http://www.thymeleaf.org" style="height: 100%">
<body class="body_hei edit">
<style>
    .layui-form-item{border: none !important;background: none !important;}
</style>
<div th:replace="include/head.html::html"></div>
<form class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin" style="padding: 20px 0 0 0;background-color: #FFFFFF;height: 100%">
    <input type="hidden" name="oid" th:value="${sysUserPermission?.oid}">
    <input type="hidden" name="userOid" th:value="${userOid}">
    <div class="layui-form-item">
        <label class="layui-form-label">权限名称:</label>
        <div class="layui-input-inline">
            <input type="text" name="title" lay-verify="required" placeholder="请选择权限" autocomplete="off" class="layui-input" >
            <input type="hidden" name="permissionOid" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">授权时间:</label>
        <div class="layui-input-block">
            <div class="layui-input-inline">
                <input type="text" class="layui-input" readonly id="startTime" name="startTime" placeholder=" - ">
            </div>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" readonly id="endTime" name="endTime" placeholder=" - ">
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block" style="width: 80%;">
            <textarea name="remark" placeholder="请输入内容" lay-verify="required" class="layui-textarea" th:text="${sysUserPermission?.remark}"></textarea>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="submit" id="submit" value="确认">
    </div>
</form>
<script type="text/javascript" th:inline="javascript">
    var userOid = [[${userOid}]];
    layui.use(['index','layer', 'form', 'upload', 'layedit', 'laydate'], function () {
        var $ = layui.$
            , form = layui.form
            , upload = layui.upload;
        var layedit = layui.layedit;
        var layer = layui.layer;
        var laydate = layui.laydate;
        //分两个的时间控件
        var start = laydate.render({
            elem: '#startTime',
            trigger: 'click',
            value: new Date(),
            type: 'datetime',
            done: function (value, date) {
                end.config.min = {
                    year: date.year,
                    month: date.month - 1,
                    date: date.date,
                    hours: date.hours,
                    minutes: date.minutes,
                    seconds: date.seconds
                }
            }
        });
        var end = laydate.render({
            elem: '#endTime',
            trigger: 'click',
            type: 'datetime',
            done: function (value, date) {
                start.config.max = {
                    year: date.year,
                    month: date.month - 1,
                    date: date.date,
                    hours: date.hours,
                    minutes: date.minutes,
                    seconds: date.seconds
                }
            }
        });
        $("input[name='title']").on('click',function () {
            selectList();
        });
        function selectList() {
            editLayer({
                title:'选择权限',
                url:'permission/selectList?userOid=' + userOid,
                area:['50%','80%'],
                back:function (ifr,index,data) {
                    $("input[name='title']").val(data.field.title);
                    $("input[name='permissionOid']").val(data.field.oid);
                    topLayer.close(index);
                }
            });
        }
    });
</script>
</body>
</html>